package com.xyc.student.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xyc.student.common.Result;
import com.xyc.student.entity.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.xyc.student.service.IDictService;
import com.xyc.student.entity.Dict;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * icon 前端控制器
 * </p>
 *
 * @author xyc
 * @since 2022-03-10
 */
@RestController
@RequestMapping("/dict")
public class DictController {

    @Resource
    private IDictService dictService;

    // 新增或者更新
    @PostMapping
    public boolean save(@RequestBody Dict dict) {
        return dictService.saveOrUpdate(dict);
    }

    @DeleteMapping("/{id}")
    public Boolean delete(@PathVariable Integer id) {
        return dictService.removeById(id);
    }

    @PostMapping("/del/batch")
    public boolean deleteBatch(@RequestBody List<Integer> ids) {
        return dictService.removeByIds(ids);
    }

    @GetMapping
    public List<Dict> findAll() {
        return dictService.list();
    }

    @GetMapping("/{id}")
    public Dict findOne(@PathVariable Integer id) {
        return dictService.getById(id);
    }


}

